package com.caojing.syby.ui.cart;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.caojing.syby.ui.cart.cartsharefragment.CartShareFragment;

import java.util.List;

/**
 * Created by Administrator on 2016/10/5 0005.
 */
public class CarfragmentViewpagerAdapter extends FragmentPagerAdapter{
   private List<CartShareFragment>cartShareFragmentList;
    private String[]tabNames;

    public CarfragmentViewpagerAdapter(FragmentManager fm, List<CartShareFragment>cartShareFragmentList, String[]tabNames) {
        super(fm);
        this.cartShareFragmentList=cartShareFragmentList;
        this.tabNames=tabNames;
    }

    @Override
    public Fragment getItem(int position) {
        return cartShareFragmentList!=null?cartShareFragmentList.get(position):null;
    }

    @Override
    public int getCount() {
        return cartShareFragmentList!=null?cartShareFragmentList.size():0;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return tabNames[position%cartShareFragmentList.size()];
    }
}
